package com.artpri.action.user;

import java.util.List;

import com.artpri.action.BaseAction;
import com.artpri.model.DeliverAdd;

/**
 * 用户收货地址 
 * @author ZhangSi
 */
public class DeliverAddAction extends BaseAction {

	private static final long serialVersionUID = -3750591988608163127L;

	private DeliverAdd address; //添加 更新
	private String province;
	private String city;
	private String town;

	private Boolean msg = false; // 消息

	private List<DeliverAdd> addList; // 列表

	private Integer id; //删除
	
	private int addNum;

	/**
	 * 地址添加
	 */
	public String addDeliverAdd() throws Exception {
		address.setUserNum(getSessionUser().getUserNum());
		getDeliverAddService().addDeliver(address, province, city, town);
		msg = true;
		return SUCCESS;
	}

	/**
	 * 地址列表
	 */
	public String listDeliverAdd() throws Exception {
		addList = getDeliverAddService().listDeliver(getSessionUser().getUserNum());
		addNum = getDeliverAddService().getAddressCount(getSessionUser().getUserNum());
		return SUCCESS;
	}
	
	/**
	 * 地址删除
	 */
	public String deleteDeliverAdd() throws Exception {
		getDeliverAddService().deleteDeliver(id);
		return SUCCESS;
	}
	
	/**
	 * 地址更新  
	 */
	public String updateDeliverAdd() throws Exception {
		address = getDeliverAddService().get(id);
		return SUCCESS;
	}
	
	/**
	 * 设置默认地址
	 */
	public String setDefaultAdd() throws Exception {
		getDeliverAddService().setDefaultAdd(getSessionUser().getUserNum(), id);
		return SUCCESS;
	}
	
	public DeliverAdd getAddress() {
		return address;
	}

	public void setAddress(DeliverAdd address) {
		this.address = address;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getTown() {
		return town;
	}

	public void setTown(String town) {
		this.town = town;
	}

	public Boolean getMsg() {
		return msg;
	}

	public void setMsg(Boolean msg) {
		this.msg = msg;
	}

	public List<DeliverAdd> getAddList() {
		return addList;
	}

	public void setAddList(List<DeliverAdd> addList) {
		this.addList = addList;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public int getAddNum() {
		return addNum;
	}

	public void setAddNum(int addNum) {
		this.addNum = addNum;
	}
}
